using Gee;
using Meridian.Data;

namespace Meridian.Side {

public interface SideItem : GLib.Object {

    public abstract string title {get; set construct;}
    public abstract string url {get; set construct;}
    
    public abstract DataTable get_table ();
    
    public abstract HashMap<string, string> get_fields ();
    
    public void persist (Dao dao) {  
        debug("persisting...");
        var fields = get_fields ();
        foreach (var entry in get_fields ().entries) {
            print (entry.key + " : " + entry.value);
        }
        dao.insert_record (get_table (), fields);
    }
    
    public void purge (Dao dao) {        
        dao.delete_record (get_table (), get_fields ());
    }
    
    public string to_string() {
        string fields = "";
        foreach (var entry in get_fields ().entries) {
            fields += " [" + entry.key + " : " + entry.value + "]";
        }
        return fields;
    }
    
}
}